<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" style="font-size: 58.5938px; min-height: 667px;"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="format-detection" content="telephone=no">
    <title>微信在线支付</title>


    <link type="text/css" rel="stylesheet" th:href="@{/css/alipay-style.css}">
    <script th:src="@{/js/lib/inspinia/js/jquery-2.1.1.js}"></script>
    <script th:src="@{/js/MyFunction.js}"></script>
    <script th:src="@{/js/Scripts/rem.js}"></script>


    <style>
        .payInfo{margin: .2rem;font-size: .28rem;line-height: .8rem;}
        .payInfo li{display: table;width: 100%;}
        .payInfo li span{float: left;color: #969696;text-align: left;}
        .payInfo li i{float: right;color: #333333;font-style: normal;text-align: right;}
        .payInfo li a{margin: .2rem .0rem .2rem .28rem;height: .5rem;line-height: .5rem;background: #108ee9;font-size: .25rem;color: #fff;text-align: center;display: block;border-radius: .08rem;width: .8rem;float: right;}
    </style>
</head>

<body style="min-height: 667px;">
<div class="wx-title"><img  style="margin-top:10px;height: 55px" src="/images/weixinlogo.png">微信支付</div>
<div class="order-id">订单号：<span id="p_orderNo"></span></div>
<div class="price">¥<span id="lable_amount"></span></div>

<a href="javascript:void(0);" class="btn-pay" id="copyaccount" onclick="pay();" >点击跳转微信支付</a>
<div class="tip"  >
    <br>
</div>
</body>
<script>

    var key=getQueryVariable("key");
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    var min=120; //2分钟
    var payurl="";
    var phonetype=0;
    var lock=0; //1锁住，0放出
    if(isAndroid)
    {
        phonetype = 2;
    }
    else if(isiOS)
    {
        phonetype=1;
    }
    var int=self.setInterval("clock()",1000);
    function clock()
    {
        min=min-1;
        $("#copyaccount").html("正在获取支付地址("+min+"秒)");
        if (lock == 0) {
            lock = 1;
            $.ajax({
                url: "/orderList/getByKeyForUnicomCard?key=" + key + "&phonetype=" + phonetype,
                type:"get",
                contentType:"application/json",
                dataType:"json",
                async: false, //同步
                success:function(data){
                    if (data.code == "200") {
                        // console.log(data)
                        int=window.clearInterval(int);
                        $("#p_orderNo").html(data.data.orderNo);;
                        $("#lable_amount").html(data.data.amount.toFixed(2));
                        //$("#copyaccount").attr("href", data.data.payOrderUrl);
                        $("#copyaccount").html("点击跳转微信支付");
                        // window.location.href = data.data.payOrderUrl;
                        payurl= data.data.payOrderUrl;
                    }
                    else if (data.code == "300") {
                        int=window.clearInterval(int);
                        $("#copyaccount").html("订单已过期");
                    }
                    else if (data.code == "400") {
                        int=window.clearInterval(int);
                        $("#copyaccount").html("订单已支付");
                    }
                }
            });

            if(min<=0)
            {
                int=window.clearInterval(int)
                $("#p_orderNo").html("");
                $("#p_amount").html("00.00");
                $("#copyaccount").html("未获取到支付地址");
                // $("#copyaccount").attr("style", "display:none");
            }
            lock = 0;
        }
    }



    function pay() {
        //console.log(payurl);
        if(payurl!="")
        {
            window.location.href = payurl;
            top.location.href = payurl;
        }

    }

</script>
</html>